<template>
    <div class="box">
        <van-nav-bar title="标题" left-text="返回" left-arrow @click-left="() => { $router.push('/home/my') }" fixed />
        <div style="height: 45px;"></div>
        <van-contact-card type="edit" :tel="tel" :name="name" @click="onEdit" />
      <div class="a1"><van-cell-group>
            <van-cell title="店铺名称" value="内容" />
            <van-card num="2" price="2.00" desc="描述信息" title="商品标题"
                thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg">
                <template #tags>
                    <van-tag plain type="primary">￥20.10</van-tag>
                    <van-tag plain type="primary">x3</van-tag>
                </template>
                <!-- <template #footer>
                    <van-button size="mini">按钮</van-button>
                    <van-button size="mini">按钮</van-button>
                </template> -->
            </van-card>

        </van-cell-group></div>  
<div class="a1"><!-- 优惠券单元格 -->
<van-coupon-cell
  :coupons="coupons"
  :chosen-coupon="chosenCoupon"
  @click="showList = true"
/>
<!-- 优惠券列表 -->
<van-popup
  v-model:show="showList"
  round
  position="bottom"
  style="height: 90%; padding-top: 4px;"
>
  <van-coupon-list
    :coupons="coupons"
    :chosen-coupon="chosenCoupon"
    :disabled-coupons="disabledCoupons"
    @change="onChange"
    @exchange="onExchange"
  />
</van-popup></div>

<div class="a1">  <van-cell-group>
            <van-cell title="商品金额" value="￥60.30" />
            <van-cell title="优惠金额" value="0" />
            <van-cell title="运费" value="免运费" />
            <van-cell title="备注" value="123123" />
        </van-cell-group></div>
      
        <van-submit-bar :price="3050" button-text="提交订单" @submit="onSubmit" />

    </div>
</template>

<script setup>
import { ref } from 'vue';
import { showToast } from 'vant';
const tel = ref('13000000000');
const name = ref('张三');
const onEdit = () => showToast('edit');
const onSubmit = () => showToast('点击按钮');
const coupon = {
    available: 1,
    condition: '无门槛\n最多优惠12元',
    reason: '',
    value: 150,
    name: '优惠券名称',
    startAt: 1489104000,
    endAt: 1514592000,
    valueDesc: '1.5',
    unitDesc: '元',
};

const coupons = ref([coupon]);
const showList = ref(false);
const chosenCoupon = ref(-1);

const onChange = (index) => {
    showList.value = false;
    chosenCoupon.value = index;
};
const onExchange = (code) => {
    coupons.value.push(coupon);
};

</script>

<style lang="scss" scoped>
.box{
    background-color: #e8e8e8;
}
.a1{
    background-color: #fff;
    margin:20px 0;
}</style>